#include <bits/stdc++.h>
using namespace std;
int main() {
  // select value <= target item
  // select min value item
  // erase
  using u64 = unsigned long long;
  multiset<u64> coins;
  int n;
  cin >> n;
  while (n--) {
    u64 coin;
    cin >> coin;
    coins.insert(coin);
  }
  u64 p1 = 0, p2 = 0;
  auto select = [&](u64 &sum) {
    auto iter = coins.upper_bound(sum);
    if (iter != coins.begin()) iter--;
    sum += *iter;
    coins.erase(iter);
  };
  while (!coins.empty()) {
    select(p1);
    if (coins.empty()) break;
    select(p2);
  }
  cout << p1 << ' ' << p2 << endl;
}